// server/src/routes/content.ts
import { Router } from 'express'
import { 
  getContents, 
  getContent, 
  createContent, 
  updateContent, 
  deleteContent,
  getContentBySlug 
} from '../controllers/contentController'
import { authenticateToken, requireAdmin } from '../middleware/auth'

const router = Router()

// 公开路由 - 所有人都可以访问
router.get('/', getContents)
router.get('/:id', getContent)
router.get('/slug/:slug', getContentBySlug)

// 需要管理员权限的路由
router.post('/', authenticateToken, requireAdmin, createContent)
router.put('/:id', authenticateToken, requireAdmin, updateContent)
router.delete('/:id', authenticateToken, requireAdmin, deleteContent)

export default router